{extend name="layout" /}

{block name="breadcrumb"}
<h2>{$title}{$typeName}</h2>
<ol class="breadcrumb">
    <li><a href="{:url('index/index')}">首页</a></li>
    <li><a href="{:url('lang/index')}">语种列表</a></li>
    <li><strong>{$lang}</strong></li>
    <li><strong>{$className}</strong></li>
    <li><strong>{$courseName}</strong></li>
    <li><a href="{:url('lang_class_recite_type/index', ['classId' => $classId, 'courseType' => $courseType, 'type' => $type, 'lang' => $lang, 'className' => $className])}">套题列表</a></li>
    <li><a href="{:url('index', ['classId' => $classId, 'courseType' => $courseType, 'type' => $type, 'lang' => $lang, 'className' => $className, 'typeId' => $typeId])}">{$typeName}列表</a></li>
    <li><strong>{$title}{$typeName}</strong></li>
</ol>
{/block}

{block name="main"}
<div class="ibox float-e-margins">
    <div class="ibox-title">
        <h5>{$title}{$typeName}</h5>
    </div>
    <div class="ibox-content">
        <form method="post" class="form-horizontal" onsubmit="return toSubmit()">

            <div class="form-group">
                <label class="col-sm-2 control-label">{$typeName}</label>
                <div class="col-sm-6">
                    <input type="text" name="word" value="{$model ? $model.word : ''}" class="form-control" required />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">声音文件</label>
                <div class="col-sm-6">
                    <div id="container">
                        <input type="hidden" name="file" id="container-input" value="{$model ? $model.file : ''}">
                        <input type="hidden" name="fileSize" id="container-size-input" value="">
                        <div id="file-container">
                            {if ( $model && $model.file ) }
                            <p class="upload_old_img">
                                <audio src="{:config('file_prefix').$model.file}" controls="controls">
                                    您的浏览器不支持 audio 标签。
                                </audio>
                            </p>
                            {/if}
                        </div><br/>
                        <a href="javascript:void(0);" id="select-container" class='btn btn-info'>选择声音文件</a>
                        <a href="javascript:void(0);" id="post-container" class='myPostFiles btn btn-info'>上传声音文件</a>
                        <span>（格式：mp3；大小：50mb以内）</span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">答案</label>
                <div class="col-sm-8">
                    <div class="row">
                        {foreach $answers as $k=>$v}
                        <div class="col-sm-3 margin-bottom-10">
                            <div id="container{$k}">
                                <input type="hidden" name="answer[{$k}][id]" value="{$v.id}">
                                <input type="hidden" name="answer[{$k}][image]" id="container{$k}-input" value="{$v.image}">
                                <input type="hidden" name="answerFileSize" id="container{$k}-size-input" value="">
                                <div id="file-container{$k}">
                                    {if ( $v && $v.image ) }
                                    <p class="upload_old_img upload_img_box">
                                        <img src="{:config('file_prefix').$v.image}" alt="" >
                                    </p>
                                    {/if}
                                </div><br/>
                                <a href="javascript:void(0);" id="select-container{$k}" class='btn btn-primary'>选择文件</a>
                                <a href="javascript:void(0);" id="post-container{$k}" class='myPostFiles btn btn-primary'>开始上传</a>
                            </div>
                            {$v.label}<input type="text" class="form-control" name="answer[{$k}][answer]" value="{$v.answer}" required>
                        </div>
                        {/foreach}

                    </div>

                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">权重</label>
                <div class="col-sm-6">
                    <input type="text" name="sort_num" value="{$model ? $model.sort_num : 0}" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-6">
                    <select name="status" class="form-control" required>
                        {foreach $status as $key=>$vo }
                        {if ( $model && $model.status == $key ) }
                        <option value="{$key}" selected>{$vo}</option>
                        {else /}
                        <option value="{$key}">{$vo}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">正确答案</label>
                <div class="col-sm-6">
                    {foreach $answers as $k=>$v}
                    <div class="radio radio-info radio-inline">
                        <input type="radio" name="is_right" id="inlineRadio{$k}" value="{$k}"
                               required {$v['is_right'] == 1 ? 'checked' : '' } />
                        <label for="inlineRadio{$k}"> {$v.label} </label>
                    </div>
                    {/foreach}
                </div>
            </div>

            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    {if ( $model && $model.id > 0) }
                    <input type="hidden" name="id" value="{$model.id}">
                    {/if}
                    <input type="hidden" name="lang" value="{$lang}">
                    <input type="hidden" name="className" value="{$className}">
                    <input type="hidden" name="class_id" value="{$classId}">
                    <input type="hidden" name="course_type" value="{$courseType}">
                    <input type="hidden" name="type" value="{$type}">
                    <input type="hidden" name="type_id" value="{$typeId}">
                    <button class="btn btn-primary" type="submit" id="mySubmitBtn">提交</button>
                    <button class="btn btn-white" type="button"><a href="{:url('index', ['classId' => $classId, 'courseType' => $courseType, 'type' => $type, 'lang' => $lang, 'className' => $className, 'typeId' => $typeId])}">取消</a></button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="jsFile"}
{load href="/static/js/plugins/plupload/js/plupload.full.min.js" /}
<script>
    window.PHP = {
        containerIds: ['container', 'container0', 'container1', 'container2', 'container3'],
        uploadUrl: "{:url('upload/file', ['type' => '__TYPE__', 'dir' => 'lang_recite'])}",
        uploadType: [2, 1, 1, 1, 1],
        maxSize: '100gb',
        fileNum: 1,
        extensions: ["mp3"]
    };
</script>
{load href="/static/js/plugins/plupload/upload.js" /}
{/block}